// pages/group.js
Page({
  /**
   * 页面的初始数据
   */
  data: {
    tabbar_active:2,
    weather:[],
    citycode:[],
    city:"",
    cityname:"",
    weatherkey:"(和风天气api申请的key)"
  },
  setCity:function(e){
    var val=e.detail.value;
    this.setData({city:val})
  },
  getWeather(event){
    wx.request({
      url:'https://geoapi.qweather.com/v2/city/lookup?location='+this.data['city']+'&&key='+this.data['weatherkey'],
      success:res1=>{
        this.setData({citycode:res1.data.location[0].id}),
        console.log("[1]"+this.data['citycode']),
        wx.request({
          url: 'https://devapi.qweather.com/v7/weather/now?location='+this.data['citycode']+'&&key='+this.data['weatherkey'],
          success:res2=>{
            console.log("[2]"+this.data['citycode']),
          this.setData({weather:res2.data})
          }
        })
      }
    })
  },
  /**
   * 导航栏函数
   */
  backtoHome(event){
    wx.navigateBack({
      delta: 0,
    })
  },
  gotoSearch(event){
    wx.navigateTo({
      url: '../example/examples',
    })
  },
  gotoGroup(event){
    wx.navigateTo({
      url: '../group/group',
    })
  },
  gotoSetting(event){
    wx.navigateTo({
      url: '../setting/setting',
    })
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {

  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})